# 电子表格
from lark_oapi.api.sheets.v3 import *
from common.client import get_client

# 创建电子表格
def create(title, folder_token):
    client = get_client()
    request: CreateSpreadsheetRequest = CreateSpreadsheetRequest.builder() \
        .request_body(Spreadsheet.builder()
                      .title(title)
                      .folder_token(folder_token)
                      .build()) \
        .build()
    response: CreateSpreadsheetResponse = client.sheets.v3.spreadsheet.create(request)

    if not response.success():
        raise RuntimeError(f"创建电子表格失败,失败原因:{response.msg}")

    return response.data.spreadsheet.spreadsheet_token